#include <iostream>
#include <algorithm>
#include <vector> 
#include <string>
#include <list>
#include <fstream> 
#include <iomanip>
#include <math.h>
using namespace std;

bool get_number(string line_string, vector<double>& temp)
{
	temp.clear();
	for (int i = 0; i < line_string.size(); ++i) {
		if ((line_string[i] >= 48 && line_string[i] <= 57) || line_string[i] == 45) {
			double temp_value = 0;
			int j = i;
			int n = -1;
			bool flag = true;
			for (; j < line_string.size(); ++j) {
				if (line_string[j] == 45) {
					flag = false;
					continue;
				}
				if (line_string[j] == 44 || line_string[j] == 59) {
					break;
				}
				if (line_string[j] >= 48 && line_string[j] <= 57) {
					temp_value = temp_value * 10 + line_string[j] - 48;
				}
				if (line_string[j] == 46)
					n = j;
			}
			temp_value = n == -1 ? temp_value : temp_value / pow(10, j - n - 1);
			if (!flag)
				temp_value = temp_value * -1;
			temp.push_back(temp_value);
			i = j;

		}
	}
	return true;
}

int main(){
    string txt1 = "1.txt", txt2 = "2.txt";
    fstream assist_file_name(txt1);
    ofstream out_file(txt2);
    int base_x = 662-699;
    int base_y = 95-96; 
    if (!assist_file_name)
		return 0;
    string temp_name,first_name;
    vector<vector<int>> roi;
    vector<vector<double>> point;
    vector < double> temp;
		//
    getline(assist_file_name, temp_name);
    first_name = temp_name;
    get_number(temp_name, temp);
    int n = temp[temp.size() - 1];
    for (int i = 0; i < 2;++i){
        getline(assist_file_name, temp_name);
        get_number(temp_name, temp);
        vector<int> temp1;
        for (int j = 0; j < temp.size();++j)
            temp1.push_back(temp[j]);
        temp1[0] += base_x;
        temp1[1] += base_y;
        roi.push_back(temp1);
    }
    for (int i = 0; i < n;++i){
        getline(assist_file_name, temp_name);
        get_number(temp_name, temp);
        // temp[1] -= 30;
        temp[2] += base_x;
        temp[3] += base_y;
        point.push_back(temp);
    }

    out_file << first_name << endl;
    for (int i = 0; i < roi.size();++i){
        out_file << roi[i][0]<<',';
        out_file << roi[i][1]<<',';
        out_file << roi[i][2]<<',';
        out_file << roi[i][3] << ';' << endl;
    }
    for (int i = 0; i < point.size();++i){
        out_file << fixed << setprecision(2) << point[i][0]<<',';
        out_file << fixed << setprecision(2) << point[i][1]<<',';
        out_file << fixed << setprecision(2) << point[i][2]<<',';
        out_file << fixed << setprecision(2) << point[i][3] << ';' << endl;
    }
    out_file.close();
}